// es6 语法声明类
class People {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
  showName() {
    console.log(this.name);
  }
}
let p1 = new People('yk', 25);
console.log(p1);

class Coder extends People {
  constructor(name, age, company) {
    super(name, age)
    this.company = company
    this._sex = -1
  }
  get sex(  ) {
    if(this._sex === 1) {
      return 'male'
    }else if(this._sex === 0) {
      return 'female'
    } else {
      return 'error'
    }
  }
  //当sex为 0 / 1 时返回 male 或者female
  set sex(sex) {
    if(sex === 0 || sex === 1) {
      this._sex = sex
    }
  }

  static getCount() {
    return 5
  }

  showCompany() {
    console.log(this.company);
  }
}
let c1 = new Coder('yk', 25, 'google')
console.log(c1);
c1.showName()
c1.showCompany()
console.log(Coder.getCount());